#include <stdio.h>
#include <assert.h>

int fits_bits(int x, int n){
    int new = x >> (n - 1);
    return (new == -1) || (new == 0);
}


int main(){

    assert(!fits_bits(0xFF, 8));
    assert(!fits_bits(~0xFF, 8));

    assert(fits_bits(0b0010, 3));
    assert(!fits_bits(0b1010, 3));
    assert(!fits_bits(0b0110, 3));

    assert(fits_bits(~0b11, 3));
    assert(!fits_bits(~0b01000011, 3));
    assert(!fits_bits(~0b111, 3));

    return 0;
}
